home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gekikoh Dennoh Club 1
/
Gekikoh Dennoh Club Vol. 1 (Japan).7z
/
Gekikoh Dennoh Club Vol. 1 (Japan) (Track 1).bin
/
tools
/
ebsx130
/
seion.c
< prev
next >
Wrap
Text File
|
1996-05-01
|
3KB
|
108 lines
#include "common.h"
#include <iocslib.h>
#include <jctype.h>
/* shift-JIS を、清音の JIS コードに変換する */
/* err があったら、NULL を返す */
jischar* seion(char *str, jischar *outp, size_l length)
{
unsigned char c,fc;
int ch;
char *s=str;
jischar *p=outp;
alpha = 0; /* kenji suzuki */
fc=0;
while (c=*s++) {
if ((ch=AKCONV(0,c))<0) {
if (iskanji(c)) {
ch=c<<8;
c=*s++;
if (iskanji2(c)) {
ch+=c;
}
} else return NULL;
}
ch=SFTJIS(ch);
if (ch==0x212b||ch==0x212c) continue;
if ((ch&0xff00)==0x2500) ch&=0x24ff; /* 片仮名を平仮名にする */
if ((ch&0xffe0)==0x2360) ch&=0x235f; /* 英小文字を大文字化 */
if (ch==0x213c||ch==0x213d||ch==0x215d) {
if (fc==0) return NULL;
switch (fc) {
case 0x22: case 0x2b: case 0x35: case 0x3f: case 0x4a:
case 0x4f: case 0x5e: case 0x64: case 0x69: case 0x6f:
ch=0x2422; break; /* あ行 */
case 0x24: case 0x2d: case 0x37: case 0x41: case 0x4b:
case 0x52: case 0x5f: case 0x6a: case 0x70:
ch=0x2424; break; /* い行 */
case 0x26: case 0x2f: case 0x39: case 0x44: case 0x4c:
case 0x55: case 0x60: case 0x66: case 0x6b:
ch=0x2426; break; /* う行 */
case 0x28: case 0x31: case 0x3b: case 0x46: case 0x4d:
case 0x58: case 0x61: case 0x6c: case 0x71:
ch=0x2428; break; /* え行 */
case 0x2a: case 0x33: case 0x3d: case 0x48: case 0x4e:
case 0x5b: case 0x62: case 0x68: case 0x6d: case 0x72:
ch=0x242a; break; /* お行 */
default: return NULL;
}
} else {
fc=0;
/* kenji suzuki */ if(( ch >= 0x2341 ) && ( ch <= 0x235a ))
{
alpha = 1;
};
if ((ch&0xff00)==0x2400) {
c=ch;
switch (c) {
/* ぁ ぃ ぅ ぇ ぉ */
case 0x21: case 0x23: case 0x25: case 0x27: case 0x29:
/* っ ゃ ゅ ょ ゎ 以上を大文字にする */
case 0x43: case 0x63: case 0x65: case 0x67: case 0x6e:
ch++; break;
case 0x2c: case 0x2e: case 0x30: case 0x32: case 0x34:
case 0x36: case 0x38: case 0x3a: case 0x3c: case 0x3e:
case 0x40: case 0x42: case 0x45: case 0x47: case 0x49:
case 0x50: case 0x53: case 0x56: case 0x59: case 0x5c:
ch--; break; /* 濁点を取る */
case 0x51: case 0x54: case 0x57: case 0x5a: case 0x5d:
ch-=2; break; /* 半濁点を取る */
case 0x75: ch=0x242b; break;
case 0x76: ch=0x2431; break;
/* kenji suzuki */ case 0x74: ch=0x2426; break; /* ヴ->う */
}
fc=ch;
}
c=ch>>8;
/* if ((ch&0xffc0)!=0x2340 && c!=0x24 && c<0x30 && ch!=0x213a) */
/* kenji suzuki */ if ((ch&0xffc0)!=0x2340 && c!=0x24 && c<0x30 && ch!=0x213a && ch!=0x2121)
return NULL;
}
/* *p++=JISSFT(ch); */
*p++=ch;
}
*p++=0;
/* p=outp;
while (ch=*p++) {
ch=JISSFT(ch);
putchar(ch>>8); putchar(ch);
putchar('\n');
}
*/ return outp;
}
/*
#include <stdio.h>
int main(int argc, char *argv[])
{
char out[10000];
char *p;
p=seion(argv[1],out,sizeof(out));
if (p==NULL) p="(NULL)";
puts(p);
}
*/